<template>
	<view class="message-page">
		<TopBar
			left-icon="/static/user.png"
			scan-icon="/static/saoyisao.png"
			menu-icon="/static/menu.png"
			@menu="toggleMenu"
		/>

		<scroll-view scroll-y class="form-scroll">
			<view class="back-row" @click="goBack">
				<image class="back-arrow-icon" src="/static/left.png" mode="aspectFit" />
			</view>

			<view class="tabs">
				<view class="tab active">Message box</view>
			</view>

			<view class="list">
				<view class="list-item" v-for="(item, idx) in messageList" :key="idx">
					<view class="message-icon" :style="{ backgroundColor: item.color }"></view>
					<text class="title">{{ item.title }}</text>
					<text class="date">{{ item.date }}</text>
				</view>
			</view>
		</scroll-view>

		<AccountMenu
			v-if="showMenu"
			:style="{ '--anchor-top': '70px', '--anchor-right': '16px' }"
			@close="closeMenu"
			@select="closeMenu"
		/>

		<CustomTabbar active="visitors" />
	</view>
</template>

<script setup>
import { ref } from 'vue';
import TopBar from '@/components/TopBar.vue';
import AccountMenu from '@/components/AccountMenu.vue';
import CustomTabbar from '@/components/CustomTabbar.vue';

const showMenu = ref(false);
const toggleMenu = () => { showMenu.value = !showMenu.value; };
const closeMenu = () => { showMenu.value = false; };
const goBack = () => {
    uni.navigateTo({ url: '/pages/person/person' });
};

const messageList = ref([
	{ color: '#4CAF50', title: 'MTR Completed', date: '10/09/2025' },
	{ color: '#E91E63', title: 'Shipment question', date: '10/09/2025' }
]);
</script>

<style lang="scss">
.message-page { min-height: 100vh; background: linear-gradient(180deg, #d9f0ff 0%, #e9f9ed 100%); }
.form-scroll { margin-top: 60px; padding: 0 16px 84px 16px; box-sizing: border-box; }
.back-row { margin: 12px 0 0 -8px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.back-arrow-icon { width: 24px; height: 24px; }
.tabs { display: flex; gap: 8px; margin: 8px 0 0; }
.tab { padding: 8px 12px; background: #e6f0f5; color: #23323a; border-radius: 8px; font-weight: 700; }
.tab.active { background: #23323a; color: #fff; }
.list { display: flex; flex-direction: column; gap: 0; margin-top: -5px; }
.list-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: 0 2px 8px rgba(0,0,0,.08); border: 1px solid #e0e0e0; }
.message-icon { width: 30px; height: 30px; border-radius: 50%; }
.title { flex: 1; color: #0b1e2a; font-size: 14px; }
.date { color: #3b5560; font-size: 12px; }
</style>
